<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>ListLines</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>ListLines</h1>

<p>Displays the script lines most recently executed.</p>

<pre class="Syntax">ListLines [, On|Off]</pre>
<h3>Parameters</h3>
<dl>

  <dt>On|Off</dt>
  <dd><p>If blank or omitted, the history of lines most recently executed is shown. In v1.0.48.01+, an optional first parameter was added, which can be either On or Off. It affects only the behavior of the <a href="../misc/Threads.htm">current thread</a> as follows:</p>
      <p><strong>On</strong>: Includes subsequently-executed lines in the history. This is the starting default for all scripts.</p>      
      <p><strong>Off</strong>: Omits subsequently-executed lines from the history.</p></dd>

</dl>

<h3>Remarks</h3>
<p>ListLines (with no parameter) is equivalent to selecting the &quot;View-&gt;Lines most recently executed&quot; menu item in the main window. It can help <a href="../Scripts.htm#debug">debug a script</a>.</p>
<p><code>ListLines Off/On</code> can be used to selectively omit some lines from the history, which can help prevent the history from filling up too quickly (such as in a loop with many fast iterations). <code>ListLines Off</code> may also improve performance by a few percent.</p>
<p>Every newly launched <a href="../misc/Threads.htm">thread</a> (such as a <a href="../Hotkeys.htm">hotkey</a>, <a href="Menu.htm">custom menu item</a>, or <a href="SetTimer.htm">timed</a> subroutine) starts off fresh with the default setting for this command. That default may be changed by using this command in the auto-execute section (top part of the script).</p>
<p>Although there is no built-in variable &quot;A_ListLines&quot;, similar functionality can be achieved by including the following in a script:</p>
<pre>ListLines(PassTrueToTurnOnOrFalseToTurnOff)  <em>; Returns the previous setting of ListLines (prior to this call).</em>
{
    static sListLines := true  <em>; The starting default for all scripts is &quot;ListLines On&quot;.</em>
    ListLines % PassTrueToTurnOnOrFalseToTurnOff ? &quot;On&quot; : &quot;Off&quot;  <em>; Execute ListLines unconditionally to omit the lines executed below from the log.</em>
    ListLines_prev := sListLines
    sListLines := PassTrueToTurnOnOrFalseToTurnOff
    return ListLines_prev
}

<em>; To use the above function:</em>
prev_ListLines := ListLines(false)  <em>; Turn off ListLines temporarily.
; ...</em>
ListLines(prev_ListLines)  <em>; Restore ListLines to its previous setting.</em></pre>
<p>On a related note, the built-in variables <a href="../Variables.htm#LineNumber">A_LineNumber</a> and <a href="../Variables.htm#LineFile">A_LineFile</a> contain the currently executing line number and the file name to which it belongs.</p>
<h3>Related</h3>
<p><a href="KeyHistory.htm">KeyHistory</a>, <a href="ListHotkeys.htm">ListHotkeys</a>, <a href="ListVars.htm">ListVars</a></p>
<h3>Example</h3>
<pre class="NoIndent">ListLines
ListLines Off</pre>

</body>
</html>
